package edu.gdut.thesissys.vo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * Major entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "major", catalog = "gdutmis")
public class Major extends BaseVo implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2924149045430700357L;
	// Fields

	private Integer majorId;
	private Department department;
	private String name;
	private Set<Student> students = new HashSet<Student>(0);
	private Set<Teacher> teachers = new HashSet<Teacher>(0);
	private Set<GraduationSchedule> graduationSchedules = new HashSet<GraduationSchedule>(
			0);

	// Constructors

	/** default constructor */
	public Major() {
	}

	/** minimal constructor */
	public Major(String name) {
		this.name = name;
	}

	/** full constructor */
	public Major(Department department, String name, Set<Student> students,
			Set<Teacher> teachers, Set<GraduationSchedule> graduationSchedules) {
		this.department = department;
		this.name = name;
		this.students = students;
		this.teachers = teachers;
		this.graduationSchedules = graduationSchedules;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "major_id", unique = true, nullable = false)
	public Integer getMajorId() {
		return this.majorId;
	}

	public void setMajorId(Integer majorId) {
		this.majorId = majorId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "department_id")
	public Department getDepartment() {
		return this.department;
	}

	public void setDepartment(Department department) {
		this.department = department;
	}

	@Column(name = "name", nullable = false, length = 30)
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "major")
	public Set<Student> getStudents() {
		return this.students;
	}

	public void setStudents(Set<Student> students) {
		this.students = students;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "major")
	public Set<Teacher> getTeachers() {
		return this.teachers;
	}

	public void setTeachers(Set<Teacher> teachers) {
		this.teachers = teachers;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "major")
	public Set<GraduationSchedule> getGraduationSchedules() {
		return this.graduationSchedules;
	}

	public void setGraduationSchedules(
			Set<GraduationSchedule> graduationSchedules) {
		this.graduationSchedules = graduationSchedules;
	}

}